package com.charlie.beans;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Вова
 */
@Entity
@Table(name = "STATUS_DICT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "StatusDict.findAll", query = "SELECT s FROM StatusDict s"),
    @NamedQuery(name = "StatusDict.findByStatusDictId", query = "SELECT s FROM StatusDict s WHERE s.statusDictId = :statusDictId"),
    @NamedQuery(name = "StatusDict.findByStatusName", query = "SELECT s FROM StatusDict s WHERE s.statusName = :statusName")})
public class StatusDict implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "STATUS_DICT_SEQ")
    @SequenceGenerator(name = "STATUS_DICT_SEQ", sequenceName = "STATUS_DICT_STATUS_DICT_ID_SEQ", allocationSize = 1)
    @Column(name = "STATUS_DICT_ID")
    private Integer statusDictId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "STATUS_NAME")
    private String statusName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "statusDictId")
    private Collection<SoHistory> soHistoryCollection;

    public StatusDict() {
    }

    public StatusDict(Integer statusDictId) {
        this.statusDictId = statusDictId;
    }

    public StatusDict(Integer statusDictId, String statusName) {
        this.statusDictId = statusDictId;
        this.statusName = statusName;
    }

    public Integer getStatusDictId() {
        return statusDictId;
    }

    public void setStatusDictId(Integer statusDictId) {
        this.statusDictId = statusDictId;
    }

    public String getStatusName() {
        return statusName;
    }

    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }

    @XmlTransient
    public Collection<SoHistory> getSoHistoryCollection() {
        return soHistoryCollection;
    }

    public void setSoHistoryCollection(Collection<SoHistory> soHistoryCollection) {
        this.soHistoryCollection = soHistoryCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (statusDictId != null ? statusDictId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StatusDict)) {
            return false;
        }
        StatusDict other = (StatusDict) object;
        if ((this.statusDictId == null && other.statusDictId != null) || (this.statusDictId != null && !this.statusDictId.equals(other.statusDictId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.charlie.beans.StatusDict[ statusDictId=" + statusDictId + " ]";
    }
    
}
